package auth

import (
	"beluga/tools"
	"fmt"

	"github.com/astaxie/beego"
	"github.com/astaxie/beego/orm"
)

//UsersListController 登录控制器
type UsersListController struct {
	beego.Controller
}

//UserList 用户列表
type UserList struct {
	Users []orm.Params `json:"users"`
	//Users []models.User `json:"users"`
}

//Get 获取用户列表
func (c *UsersListController) Get() {
	o := orm.NewOrm()
	var us []orm.Params
	var ul UserList
	//QuerySession := models.Session{Value: cookie}
	qs, _ := o.QueryTable("user").Values(&us, "Id", "FirstName", "LastName", "UserName", "CreateTime")
	fmt.Printf("Result Nums: %d\n", qs)
	for _, q := range us {
		ul.Users = append(ul.Users, q)
	}
	res := tools.ReturnOK(0, "SUCCESS", ul)
	c.Data["json"] = res
	c.ServeJSON()
}
